--[[
 * 免疫buff添加
 *
 * 这个效果类型, 触发时机一定是 36(buff添加前)
]]

---@class BuffEffect26 : BaseBuffEffect
BuffEffect26 = ClientFight.CreateClass("BuffEffect26", ClientFight.BaseBuffEffect)
local t = BuffEffect26
---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...}
    local result = parameters[2];
    if (result.damage > 0) then
        --别人已经免疫过了,就不要再免疫了,因为大部分的免疫类 buff 都是触发后移除,
        --所以, 如果有多个这种buff, 如果这里不阻断, 那么, 全都会触发一遍, 白白浪费了 一堆的 免疫buff
        return IBuffEffect.FAIL;
    end
    local addBuff = parameters[1];
    if (addBuff == buff) then
        return IBuffEffect.FAIL;
    end
    local f_buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local type = f_buffEffectValue[1];
    if (addBuff.buffBean.f_BuffType == type) then
        result.state = DamageResultTypeEnum.IMMUNITY;
        result.damage = result.damage + 1;
        SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff:"
                .. buff.modelId .. " 免疫buff: " .. addBuff.buffBean.f_BuffId);
    else
        return IBuffEffect.FAIL;
    end
    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
end

t.New()